<?php

namespace app\office\controller;

use think\Request;
use app\office\controller\Base;
use app\office\model\Document as DocumentModel;
use app\office\model\DocumentPocess as DocumentProcessModel;

class Index extends OfficeBase
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index(Request $request)
    {
      //验证Cookie↓
      $this->checkCookie();
      // 引入navbar
      $this->setNavbar();
      $this->assign('title',"设计文件列表");
      // 此处根据是否有搜索信息来进行筛选
      
      // 获取待办document信息
      $documentList=DocumentModel::hasWhere('documentProcess', ['execute_code' => $request->cookie('login_code'),'is_fixed'=>0])->select();
      $this->assign('countall',count($documentList));
      $this->assign('documentList',$documentList);
      return $this->fetch();
    }

    public function index_document(Request $request,$type='finish')
    {
      //验证Cookie↓
      $this->checkCookie();
      // 引入navbar
      $this->setNavbar();
      $this->assign('title',"设计文件列表");
      // 此处根据是否有搜索信息来进行筛选
      if('finish'==$type){
        $is_fixed=1;
        $typeText='已办';
      }elseif('wait'==$type){
        $is_fixed=0;
        $typeText='待办';
      }else{
        $this->error('不正常数据,请联系管理员','index','',2);
      }
      // 获取已办document信息
      $documentList=DocumentModel::hasWhere('documentProcess', ['execute_code' => $request->cookie('login_code'),'is_fixed'=>$is_fixed])->select();
      $this->assign('countall',count($documentList));
      $this->assign('documentList',$documentList);
      $this->assign('typeText',$typeText);
      
      return $this->fetch();
    }

    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {
        //
    }

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        //
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read($id)
    {
        //
    }

    /**
     * 显示编辑资源表单页.
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        //
    }
}
